Quiet down dev output: demote browser-made request logs, hide Vite internals - #14956
Quiet down dev output: demote browser-made request logs, hide Vite internals#14956nickpatt wants to merge 2 commits into
Conversation
🦋 Changeset detectedLatest commit: 24c0715 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
7147eed to
6c7a7ec
Compare
| // Still log these when the Worker actually broke serving them. An unserved | ||
| // path answers 404, so only a 5xx counts as a failure worth surfacing. | ||
| if (LOG_NOISE_PATHS.has(url.pathname) && res.status < 500) return res; |
There was a problem hiding this comment.
I don't think we should drop any logs from the terminal. They are all legit request. If we find them noisy, how about filtering them in the Local Explorer UI? There could be toggles for user to opt-out too if they wanna see everything.
A browser fetches /favicon.ico on its own and Chrome DevTools probes a .well-known path on every page load. Neither is a request the developer made, and on a page you reload often they crowd out the app's own traffic. Demoted to debug rather than dropped, so the default session is quiet but --log-level debug still shows every request the Worker served. A 5xx stays at info, so a handler that broke is never quietly demoted.
6c7a7ec to
4a3a426
Compare
| // Filter in SQL, not on the returned rows, so LIMIT counts only visible logs. | ||
| if (!SHOW_VITE_INTERNALS) { | ||
| where.push(`(l.level = 'error' OR NOT ${LOG_IS_VITE_INTERNAL})`); | ||
| } |
There was a problem hiding this comment.
🟡 Start-up messages printed by your own Worker disappear from the local Logs view when using the Vite plugin
Console output produced while your Worker's modules are first loaded is filtered out of the Logs list (LOG_IS_VITE_INTERNAL used at packages/local-explorer-ui/src/utils/observability.ts:722) together with Vite's own plumbing output, so messages you wrote yourself silently never appear.
Impact: Under vite dev, anything logged at module top level (e.g. a start-up banner or a library's init message) is missing from the Local Explorer's Logs view with no indication it was hidden.
How module-evaluation logs end up attributed to the runner-dispatch span
Vite's module runner evaluates the user's modules inside the runner Durable Object via stub.executeCallback(id) (packages/vite-plugin-cloudflare/src/workers/runner-worker/module-runner.ts:51). That RPC produces an invocation whose onset span is named jsrpc with jsrpc.method = executeCallback (packages/miniflare/src/workers/observability/tail-to-store.ts:125-126). Any console.log executed during that invocation is stored with that span's id (tail-to-store.ts:334-349).
runnerDispatchJsrpcSql("sp") matches exactly that span, and in a Vite session the EXISTS wrapper-span check is always satisfied, so (l.level = 'error' OR NOT LOG_IS_VITE_INTERNAL) drops every non-error log emitted during module evaluation — including the user's own top-level logs, not just Vite's. Only error-level logs survive.
The waterfall-side rule (stripDevRunnerSpans) only hides spans, so this log-level consequence is new.
Was this helpful? React with 👍 or 👎 to provide feedback.
…ility views Vite makes its own requests to drive the module runner. Those were listed as traces alongside the app's own, and their RPC dispatch showed up as logs — 8 of 11 rows in the Traces list for one real session. They aren't requests the developer made and don't exist in a deployed Worker. Matched by URL path rather than wrapper-service name, because Vite routes every request through its router worker — matching a root span by name would have hidden the user's real traffic too. The executeCallback shape rule only applies inside a trace already known to be Vite, so a wrangler dev user with an RPC method of that name keeps their logs. Failures are never hidden. The existing show/hide toggle for runner spans is untouched.
4a3a426 to
24c0715
Compare
Local dev output fills up with things you never asked for. Your browser fetches a favicon on its own. Chrome DevTools probes for a workspace file on every page load. And under the Vite plugin, your Worker runs inside a runner Durable Object behind a couple of wrapper workers, so the traces fill with machinery that doesn't exist in production.
Two separate changes, one commit each.
Browser-made requests are logged at
debug, not dropped/favicon.icoand DevTools'/.well-known/appspecific/com.chrome.devtools.jsonmove frominfotodebugin thewrangler devrequest log. A default session is quiet;--log-level debugstill shows every request the Worker served. Nothing is thrown away.If the Worker returns a 5xx serving one of them it stays at
info, so a handler that broke is never quietly demoted.Vite's internal plumbing is hidden from the Observability views
Vite's own module-init and export-type requests were listed as traces, and its module-runner RPC dispatch as logs. In one real session that was 8 of 11 rows in the Traces list. None of it exists in a deployed Worker, so it's hidden, and the show/hide toggle it used to sit behind is gone.
Span-level hiding inside a trace already existed and was already on by default — what's new is the trace list and the Events view, neither of which filtered Vite at all.
Deliberately not included
Favicon requests still appear in the Observability views. An earlier version of this PR hid them there too, and that was wrong: the Events view is built to mirror the production Logs view, and favicon requests are real requests that do show up in production. Hiding them locally would make the mirror lie. The pre-existing code already drew this line — "Favicon requests are intentionally left in — they're at least driven by real navigation" — and only the DevTools probe, which is pure tooling traffic, stays filtered there.
That's also why the terminal change demotes rather than drops: the complaint was about noise in the terminal, and demoting fixes that without pretending a request didn't happen.
Notes on the Vite filtering
executeCallbackrule only fires inside a trace already known to be Vite. Awrangler devuser can legitimately have their own RPC method with that name, and silently dropping their logs would be the worst outcome here.LIMITcounts only what you'll actually see.Checked against real capture stores from both a
vite devand awrangler devsession, including that the Vite rules leave awrangler devsession completely alone.